<?php
class CContact{
    static function main(){
        global $pageContent, $page, $message;
        $xtpl = new XTemplate('contact.html',PAGE_PATH.DS.DS.$page.DS.DS.'tpl');
        $xtpl->parse('main');
        $pageContent = $xtpl->text('main');
        
        if(isset($_POST['submit'])){
            global $message;
            $author = isset($_POST['author'])?trim($_POST['author']):"";
            $title = isset($_POST['title'])?trim($_POST['title']):"";
            $mess = isset($_POST['message'])?trim($_POST['message']):"";
            try{
                $message->add_message($author, $title, $mess);
            }catch(Exception $e){
                $pageContent = $e->getMessage();
            }
        }
    }
}
?>
